package com.gxa.order.controller;

import com.gxa.common.commons.JsonResult;
import com.gxa.common.commons.R;
import com.gxa.common.utils.FileUtils;
import com.gxa.order.pojo.CleanOrder;
import com.gxa.order.pojo.EmployeeTask;
import com.gxa.order.pojo.HouseProperty;
import com.gxa.order.service.ServiceOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;

/**
 * @Auth WK
 * @DATE 2022/10/7 14:45
 * @DESCRIBE
 */
@RestController
@RequestMapping("/service")
public class ServiceOrderController {

    @Autowired
    private ServiceOrderService serviceOrderService;

    /**
     * 1：添加房产
     * @param houseProperty
     * @return
     */
    @PostMapping("/addHouseProperty")
    public R addHouseProperty(HouseProperty houseProperty){
        return serviceOrderService.addHouseProperty(houseProperty);
    }

    /**
     *2：提交订单
     * @param cleanOrder
     * @return
     */
    @PostMapping("/addCleanOrder")
    public R addCleanOrder(CleanOrder cleanOrder){
        return serviceOrderService.addCleanOrder(cleanOrder);

    }

    /**
     * 3：用户名下房产信息的查询
     * @param userId
     * @return
     */
    @GetMapping("/findHousePropertyList")
    public JsonResult findHousePropertyList(Integer userId){
        return serviceOrderService.findHousePropertyList(userId);

    }

    /**
     * 4:用户下全部服务订单查询
     * @return
     */
    @GetMapping("/findCleanOrderAll")
    public JsonResult findCleanOrderAll(Integer userId){
        return serviceOrderService.findCleanOrderAll(userId);
    }


    /**
     * 5:用户下服务订单查询（待支付）
     * @return
     */
    @GetMapping("/findCleanOrder1")
    public JsonResult findCleanOrder1(Integer userId,Integer status){
        return serviceOrderService.findCleanOrder1(userId,status);
    }

    /**
     * 6:用户下服务订单查询（服务中）
     * @return
     */
    @GetMapping("/findCleanOrder2")
    public JsonResult findCleanOrder2(){
        return serviceOrderService.findCleanOrder2();
    }

    /**
     * 7:用户下服务订单查询（服务完成）
     * @return
     */
    @GetMapping("/findCleanOrder3")
    public JsonResult findCleanOrder3(){
        return serviceOrderService.findCleanOrder3();
    }

    /**
     * 8:用户下服务订单查询（服务暂停）
     * @return
     */
    @GetMapping("/findCleanOrder4")
    public JsonResult findCleanOrder4(){
        return serviceOrderService.findCleanOrder4();
    }

    /**
     * 9:用户下服务订单查询（点击查看详情）
     * @return
     */
    @GetMapping("/findCleanOrder5")
    public JsonResult findCleanOrder5(Integer cleanOrderId){
        return serviceOrderService.findCleanOrder5(cleanOrderId);
    }

    /**
     * 10:用户下服务订单查询（已取消）
     * @return
     */
    @GetMapping("/findCleanOrder6")
    public JsonResult findCleanOrder6(){
        return serviceOrderService.findCleanOrder6();
    }

    /**
     * 11:取消订单
     * @return
     */
    @PostMapping("/delCleanOrder")
    public R delCleanOrder(Integer cleanOrderId){
        return serviceOrderService.delCleanOrder(cleanOrderId);
    }

    /**
     * 12:点击服务中订单的查看订单详情
     * @param cleanOrderId
     * @return
     */
    @GetMapping("/findCleanOrderByStatus")
    public JsonResult findCleanOrderByStatus(Integer cleanOrderId){
        return serviceOrderService.findCleanOrderByStatus(cleanOrderId);
    }

    /**
     * 13：编辑节点状态
     * @param scheduleStatus
     * @param cleanOrderId
     * @return
     */
    @PostMapping("/updateCleanOrderStatus")
    public R updateCleanOrderStatus(Integer cleanOrderId,Integer scheduleStatus){
        return serviceOrderService.updateCleanOrderStatus(cleanOrderId,scheduleStatus);
    }

    /**
     * 14:查询员工任务
     * @param cleanOrderId
     * @return
     */
    @GetMapping("/findEmployeeTaskList")
    public JsonResult findEmployeeTaskList(Integer cleanOrderId){
        return serviceOrderService.findEmployeeTaskList(cleanOrderId);
    }

    /**
     * 15:修改员工任务状态
     * @param employeeTaskId
     * @return
     */
    @PostMapping("/updateEmployeeTaskStatus")
    public R updateEmployeeTaskStatus(Integer employeeTaskId,Integer status){
        return serviceOrderService.updateEmployeeTaskStatus(employeeTaskId,status);
    }

    /**
     * 16:添加员工任务
     * @param employeeTask
     * @return
     */
    @PostMapping("/addEmployeeTask")
    public R addEmployeeTask(EmployeeTask employeeTask){
        return serviceOrderService.addEmployeeTask(employeeTask);
    }

    /**
     * 17:取消任务
     * @param employeeTaskId
     * @return
     */
    @PostMapping("/delEmployeeTask")
    public R delEmployeeTask(Integer employeeTaskId){
        return serviceOrderService.delEmployeeTask(employeeTaskId);
    }

    /**
     * 18:查询员工任务详情
     * @param employeeTaskId
     * @return
     */
    @GetMapping("/findEmployeeTask")
    public JsonResult findEmployeeTask(Integer employeeTaskId){
        return serviceOrderService.findEmployeeTask(employeeTaskId);
    }

    /**
     * 19:订单资料查看（房产资料图）
     * @param housePropertyId
     * @return
     */
    @GetMapping("/findHouseProperty")
    public JsonResult findHouseProperty(Integer housePropertyId){
        return null;
    }

    /**
     * 20:查询该订单下的财务信息
     * @return
     */
    @GetMapping("/findFinanceList")
    public JsonResult findFinanceList(Integer cleanOrderId){
        return serviceOrderService.findFinanceList(cleanOrderId);
    }

    /**
     * 21:查询某条财务信息的详情
     * @param financeId
     * @return
     */
    @GetMapping("/findFinance")
    public JsonResult findFinance(Integer financeId){
        return serviceOrderService.findFinance(financeId);
    }

    /**
     * 22:编辑财务信息
     * @param financeId
     * @return
     */
    @PostMapping("/updateFinance")
    public R updateFinance(Integer financeId){
        return serviceOrderService.updateFinance(financeId);
    }

    /**
     * 23:付款抵扣
     * @return
     */
    @PostMapping("/updateFinanceByMoney")
    public R updateFinanceByMoney(){
        return null;
    }

    /**
     * 24:添加收付款
     * @return
     */
    @PostMapping("/addFinanceOrder")
    public R addFinanceOrder(){
        return null;
    }

    /**
     * 25:上传图片
     * @param file
     * @param request
     * @return
     */
    @PostMapping("/pictureUpLoad")
    public R pictureUpLoad(MultipartFile file, HttpServletRequest request){
        String s = FileUtils.fileUpload("/load",file,request);
        R r = new R();
        if (s!=null && s!=""){
            r.setCode(200);
            r.setMsg("图片上传成功");
            r.setData(s);
        }else {
            r.setCode(500);
            r.setMsg("图片上传故障");
        }
        return r;
    }

    /**
     * 26:查询房产信息详情
     * @return
     */
    @GetMapping("/findHousePropertyDetails")
    public JsonResult findHousePropertyDetails(Integer housePropertyId){
        return serviceOrderService.findHousePropertyDetails(housePropertyId);
    }

    /**
     * 27:查询执行人
     * @return
     */
    @GetMapping("/findExecutorList")
    public JsonResult findExecutorList(){
        return serviceOrderService.findExecutorList();
    }

    /**
     * 28:查询服务规格
     * @return
     */
    @GetMapping("/findOrderServiceList1")
    public JsonResult findOrderServiceList1(){
        return serviceOrderService.findOrderServiceList1();
    }

    /**
     * 29：查询房间规格
     * @return
     */
    @GetMapping("/findRoomAreaList1")
    public JsonResult findRoomAreaList1(Integer orderServiceId){
        return serviceOrderService.findRoomAreaList1(orderServiceId);
    }

    /**
     * 30：根据订单编号查订单id
     * @param cleanOrderNumber
     * @return
     */
    @GetMapping("/findOrderIdByNumber")
    public JsonResult findOrderIdByNumber(String cleanOrderNumber){
        return serviceOrderService.findOrderIdByNumber(cleanOrderNumber);
    }

    /**
     * 31：根据订单id编辑支付时间
     * @param cleanOrderId
     * @param payTime
     * @return
     */
    @GetMapping("/updateOrderPayTime")
    public JsonResult updateOrderPayTime(Integer cleanOrderId,String payTime){
        return serviceOrderService.updateOrderPayTime(cleanOrderId,payTime);
    }

}
